package com.jz.componet.threadPoolStudy;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadTest {
    private static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
            1,
            1,
            1,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue(5),
            new ThreadPoolExecutor.AbortPolicy());
    // 线程池某个线程执行任务出现异常，线程终止，那么线程池会重新启动一个线程加入线程队列
    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            threadPoolExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("<<<<" + Thread.currentThread().getName());
                    int a = 1 / 0;
                }
            });
        }
    }
}
